package controller

import (
	"context"
	v1 "tFilm4/api/v1"
	"tFilm4/internal/model"
	"tFilm4/internal/service"
)

type cMovieHall struct{}

var MovieHall = cMovieHall{}

func (c *cMovieHall) CreateMovieHall(ctx context.Context, req *v1.CreateMovieHallReq) (res *v1.CreateMovieHallRes, err error) {
	err = service.MovieHall().CreateMovieHall(ctx, model.CreateMovieHallInput{
		HallName:        req.HallName,
		HallDescription: req.HallDescription,
		Rows:            req.Rows,
		Cols:            req.Cols,
		Table:           req.Table,
		TotalCount:      req.TotalCount,
		EmptyCount:      req.EmptyCount,
	})
	return
}
func (c *cMovieHall) GetHallList(ctx context.Context, req *v1.GetHallListReq) (res *v1.GetHallListRes, err error) {
	count, list, err := service.MovieHall().GetHallList(ctx, model.GetHallListInput{
		PageSize:  req.PageSize,
		PageNum:   req.PageNum,
		SearchKey: req.SearchKey,
	})
	res = &v1.GetHallListRes{MovieHallInfos: list,
		MovieHallCount: count}
	return
}

func (c *cMovieHall) DelMovieHall(ctx context.Context, req *v1.DelMovieHallReq) (res *v1.DelMovieHallRes, err error) {
	err = service.MovieHall().DelMovieHall(ctx, req.HallId)
	return
}

func (c *cMovieHall) UpdateMovieHall(ctx context.Context, req *v1.UpdateMovieHallReq) (res *v1.UpdateMovieHallRes, err error) {
	err = service.MovieHall().UpdateMovieHall(ctx, req.MovieHall, req.SeatTable)
	return
}
